package db

import (
	"fmt"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"myuser/demo/dal/query"
)

var Q *query.Query

func Init() {
	var err error
	db, err := gorm.Open(mysql.Open("gorm:gorm@tcp(192.168.1.18:3306)/gorm?charset=utf8&parseTime=True&loc=Local"))
	if err != nil {
		panic(fmt.Errorf("cannot establish db connection: %w", err))
	}
	query.SetDefault(db)
	Q = query.Q
	if err != nil {
		panic(err)
	}
}
